import { post } from "../utils/request";
import type { AxiosRequestConfig } from "axios";

// 登录参数
export interface LoginParams {
  username: string;
  password: string;
}

// 登录响应
export interface LoginResponse {
  token: string;
  userInfo: {
    id: number;
    username: string;
    roles: string[];
    permissions: string[];
  };
}

// 登录方法（返回 Promise<LoginResponse>）
export function login(data: LoginParams, config?: AxiosRequestConfig) {
  return post<LoginResponse>("/login", data, config);
}
